#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTextDocument> // QTextDocument::FindFlags
#include <QSystemTrayIcon> // QSystemTrayIcon::ActivationReason
#include <QTranslator>

QT_BEGIN_NAMESPACE
class QToolButton;
QT_END_NAMESPACE

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget* parent = 0);
    ~MainWindow();

public:
    virtual void setVisible(bool);

protected:
    virtual void changeEvent(QEvent*);
    virtual void closeEvent(QCloseEvent*);
    virtual void keyPressEvent(QKeyEvent*);

private:
    //! mocked ui
    Ui::MainWindow* ui;

    //! status bar indicators
    QToolButton* _sbiColRow; // sbi: StatusBarIndicator
    QToolButton* _sbiLock;
    QToolButton* _sbiSyntax;
    QToolButton* _sbiZoomReset;
    QToolButton* _sbiZoomIn;
    QToolButton* _sbiZoomOut;
    void setupStatusBarIndicators();
    void connectSignalsAndSlots();
    void enableInvisibleActions();
    void initStates();

    //! fileName
    QString _fileName;
    void setFileName(const QString&);
    QString fileName() const;
    bool closeFile();

    //! syntax
    void setSyntax(const QString& fileSuffix);

    //! find
    QTextDocument::FindFlags findOptions();

    //! sys tray
    QSystemTrayIcon* _trayIcon;
    QMenu* _trayIconMenu;
    void createTrayIcon();

    //! i18n
    QTranslator _translator;

public slots:
    void openFile(const QString& fileName = QString());

private slots:
    void newFile();
    void saveFile();
    void saveFileAs();
    void quit();
    void loadSettings();
    void loadStates();
    void saveStates();
    void fontZoomChanged(int);
    void find(bool showReplace = false);
    void doFind();
    void replace();
    void doReplace();
    void doReplaceAll();
    void cascadeWindow(bool);
    void config();
    void lockFile(bool lock);
    void setSyntax();
    void toggleTopMost(bool topMost);
    void toggleToolbar();
    void toggleStatusbar();
    void toggleFullScreen();
    void gotoLine();
    void codeEditCursorPositionChanged();
    void codeEditFileDropped(const QString&);
    void chkUseRegExpToggled(bool);
    void trayIconActivated(QSystemTrayIcon::ActivationReason);
    void about();
};

#endif // MAINWINDOW_H
